package cn.pengpeng;
import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class MySQLMapperOutputValue implements Writable {

    private String uid;

    private String sid;

    @Override
    public void write(DataOutput out) throws IOException {

        if (this.uid == null) {
            out.writeBoolean(false);
        } else {
            out.writeBoolean(true);
            out.writeUTF(this.uid);
        }

        if (this.sid == null) {
            out.writeBoolean(false);
        } else {
            out.writeBoolean(true);
            out.writeUTF(this.sid);
        }
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        this.uid = in.readBoolean() ? in.readUTF() : null;
        this.sid = in.readBoolean() ? in.readUTF() : null;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    @Override
    public String toString() {
        return "[uid=" + uid + ", sid=" + sid + "]";
    }
}